package com.fsnbigdata.service.impl;
import com.fsnbigdata.service.api.EnterpriseProductService;
import org.springframework.roo.addon.layers.service.annotations.RooServiceImpl;
import com.fsnbigdata.domain.Enterprise;
import com.fsnbigdata.domain.EnterpriseProduct;
import com.fsnbigdata.repository.EnterpriseProductRepository;
import io.springlets.data.domain.GlobalSearch;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * = EnterpriseProductServiceImpl
 *
 * TODO Auto-generated class documentation
 *
 */
@RooServiceImpl(service = EnterpriseProductService.class)
@Service
@Transactional(readOnly = true)
public class EnterpriseProductServiceImpl implements EnterpriseProductService {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    private EnterpriseProductRepository enterpriseProductRepository;

    /**
     * TODO Auto-generated constructor documentation
     *
     * @param enterpriseProductRepository
     */
    @Autowired
    public EnterpriseProductServiceImpl(EnterpriseProductRepository enterpriseProductRepository) {
        setEnterpriseProductRepository(enterpriseProductRepository);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return EnterpriseProductRepository
     */
    public EnterpriseProductRepository getEnterpriseProductRepository() {
        return enterpriseProductRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param enterpriseProductRepository
     */
    public void setEnterpriseProductRepository(EnterpriseProductRepository enterpriseProductRepository) {
        this.enterpriseProductRepository = enterpriseProductRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param entity
     * @return EnterpriseProduct
     */
    @Transactional
    public EnterpriseProduct save(EnterpriseProduct entity) {
        return getEnterpriseProductRepository().save(entity);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return EnterpriseProduct
     */
    public EnterpriseProduct findOne(Long id) {
        return getEnterpriseProductRepository().findOne(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return EnterpriseProduct
     */
    public EnterpriseProduct findOneForUpdate(Long id) {
        return getEnterpriseProductRepository().findOneDetached(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param ids
     * @return List
     */
    public List<EnterpriseProduct> findAll(Iterable<Long> ids) {
        return getEnterpriseProductRepository().findAll(ids);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param enterprise
     * @param globalSearch
     * @param pageable
     * @return Page
     */
    public Page<EnterpriseProduct> findByEnterprise(Enterprise enterprise, GlobalSearch globalSearch, Pageable pageable) {
        return getEnterpriseProductRepository().findByEnterprise(enterprise, globalSearch, pageable);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param enterprise
     * @return Long
     */
    public long countByEnterprise(Enterprise enterprise) {
        return getEnterpriseProductRepository().countByEnterprise(enterprise);
    }

    @Override
    public List<Long> getIdsByName(String name) {
        return getEnterpriseProductRepository().getIdsByName(name);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<EnterpriseProduct> getEntityType() {
        return EnterpriseProduct.class;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Long> getIdType() {
        return Long.class;
    }
}
